#include<stdio.h>
#include<stdlib.h>
#include<assert.h>
#include<string.h>
#include<sys/socket.h>
#include<sys/types.h>
#include<arpa/inet.h>
#include<netinet/in.h>
 //20191223
int main()
{
	int sockfd = socket(PF_INET,SOCK_STREAM,0);
	assert(-1!=sockfd);
 
	struct sockaddr_in ser,cli;
	memset(&ser,0,sizeof(ser));
	ser.sin_family=AF_INET;
	ser.sin_port=htons(6000);
	ser.sin_addr.s_addr=inet_addr("127.0.0.1");
	int res=connect(sockfd,(struct sockaddr*)&ser,sizeof(ser));
	assert(res!=-1);
 
	while(1)
	{
		printf("Please input:");
		fflush(stdout);
		char buff[128]={0};
		fgets(buff,127,stdin);
		buff[strlen(buff)-1]=0;
 
		if(strncmp(buff,"end",3)==0)
		{
		    break;
		}
		send(sockfd,buff,strlen(buff),0);
 
		memset(buff,0,sizeof(buff));
		recv(sockfd,buff,127,0);
		printf("%s\n",buff);
	}
	close(sockfd);
}